package com.dw.dwdzcommerce.view.mainContent.list;

import com.dw.dwdzcommerce.R;
import com.dw.dwdzcommerce.base.fragment.BaseFragment;
import com.dw.dwdzcommerce.entity.ShopImage;
import com.dw.dwdzcommerce.tools.commons.StringUtil;
import com.dw.dwdzcommerce.tools.commons.bitmap.BitmapUtil;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class ShopImageFragment extends BaseFragment {

	private ImageView img;
	private TextView intro;
	private ShopImage mImage;

	@Override
	public int getViewLayout() {
		return R.layout.item_fragment_main_content_shop_image;
	}

	public static Fragment[] mkFragment(ShopImage[] datas) {
		Fragment[] fragments = new Fragment[datas.length];
		for (int i = 0; i < datas.length; i++) {
			ShopImage image = datas[i];
			ShopImageFragment fragment = new ShopImageFragment();
			fragment.setUpData(image);
			fragments[i] = fragment;
		}
		return fragments;
	}

	@Override
	protected void initView(View view) {
		img = (ImageView) view.findViewById(R.id.item_fragment_main_content_lis_shopimage_image);
		intro = (TextView) view.findViewById(R.id.item_fragment_main_content_lis_shopimage_intro_tv);
	}

	public void setUpData(ShopImage image) {
		mImage = image;
	}

	@Override
	protected void bindView(View view) {
		 BitmapUtil.loadImage(img, mImage.getPicUrl(), getContext());
//		img.setImageResource(R.drawable.ic_launcher);
		String introduce = mImage.getIntroduce();
		if (StringUtil.isEmpty(introduce)) {
			intro.setVisibility(View.GONE);
		} else {
			intro.setText(introduce);
		}
	}

	@Override
	public void onViewGreate(View view, Bundle savedInstanceState) {

	}

}
